package com.hl233.framework.controller;


import com.hl233.framework.common.Constants;
import com.hl233.framework.entity.BackEntity;
import com.hl233.framework.service.BackService;
import com.hl233.framework.utils.Result;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.kafka.annotation.KafkaListener;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 张振强
 * @since 2024-09-03
 */
@RestController
@RequestMapping("/back")
public class BackController {

    @Autowired
    private BackService backService;

    @ApiOperation(value = "表查询全部")
    @GetMapping("/queryAll")
    public Result queryAll() {
        return Result.ok().data("item",backService.queryAll());
    }

    @ApiOperation(value = "表新增数据")
    @PostMapping("/add")
    public Result add(@RequestBody BackEntity entity) {
        System.out.println("拿到参数"+entity);
        boolean res = backService.save(entity);
        if (res) return Result.ok();
        else return Result.error();
    }



}

